package net.tycmc.cty.ctyms.web.equiphealthstate;

import java.io.IOException;
import java.io.PrintWriter;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import net.tycmc.cty.ctyms.web.Action.BaseActionS2;

public class EquipHealthStateAction extends BaseActionS2 {
	ApplicationContext ctx = new ClassPathXmlApplicationContext(
			"/applicationContext.xml");
	EquipHealthStateService equipService = (EquipHealthStateService) ctx
			.getBean("equipHealthStateService");

	public String initEquipHealthState() {
		// 获得数据库数据量
		int count = equipService.getDataCount();
		request.setAttribute("count", count);
		return "initEquipHealthState";
	}

	public String startJob() {
		boolean result = equipService.startJob();
		response.setContentType("text/html;charset=gbk");
		PrintWriter out = null;
		try {
			out = response.getWriter();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		if (result) {
			out.print("success");
		} else {
			out.print("fail");
		}
		return null;
	}
}
